package com.dzt.trainingmgt.controller;

import java.util.Map;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.dzt.trainingmgt.Dto.Userdto;
import com.dzt.trainingmgt.utils.LogUtils;

@RestController
@SpringBootApplication
public class DataController {

	@GetMapping("/hello")
	String home_hello() {
		return "Hello hello World!";
	}
	// 收数据
	@PostMapping("/send")
    public String getdata(@RequestBody Map<String, Object> str) {
		System.out.println(str);
        return "got it";
    }

	private class Role {
		String role;

		public String getRole() {
			return role;
		}

		public void setRole(String role) {
			this.role = role;
		}
	}

	@ResponseBody
	@PostMapping("/api/login")
	public Role login(@RequestBody Userdto user) {
		LogUtils.logInfo(user.getId());
		LogUtils.logInfo(user.getPassword());
		System.out.println(user.getId());
		System.out.println(user.getPassword());
		
		// todo

		Role res = new Role();
		res.role = "员工";
		return res;
	}

	public static void main(String[] args) {
		SpringApplication.run(DataController.class, args);
	}

}